<?php

class AutoLoader {
	
    public function __construct() {
        spl_autoload_register(array($this, 'loader'));
        //spl_autoload_register(array($this, 'loaderCore'));
        //spl_autoload_register(array($this, 'loaderWorker'));
    }
    private function loader($className) {        	
        if (file_exists($className . '.php')){
			require_once $className.".php";
		}elseif(file_exists(COREPATH.$className . '.php')){
			require_once COREPATH.$className.".php";
		}elseif(file_exists(WORKERPATH.$className . '.php')){
			require_once WORKERPATH.$className.".php";
		}elseif(file_exists(BASEPATH."model/".$className . '.php')){
			require_once BASEPATH."model/".$className . '.php';
		}
    }
    private function loaderCore($className) {        	
        if (file_exists(COREPATH.$className . '.php')){
			require_once COREPATH.$className.".php";
		}
    }
    /**
	 * 自动加载worker
	 */
	private function loaderWorker($className){
		
		if (file_exists(WORKERPATH.$className . '.php')){
			include WORKERPATH.$className.".php";
		}
	}	
	
}